//
//  MK_NetWorking+MK_HomePage_Working.m
//  miku直播
//
//  Created by 杨尚达 on 2017/7/26.
//  Copyright © 2017年 杨尚达. All rights reserved.
//

#import "MK_NetWorking+MK_HomePage_Working.h"

@implementation MK_NetWorking (MK_HomePage_Working)

/// 请求得到首页分类信息数据
-(void)MK_getHomeCategoryModelArrWithBackBlock:(void(^)(NSArray<MK_HomeCategoryModel*>* res))backBlock andFailBlock:(void(^)(NSError *err))failBlock {
    
    NSString* urlStr = @"https://capi.douyucdn.cn/api/homeCate/getCateList";
    [[MK_NetWorking sharedNetWorking] Miku_GET:urlStr parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull dataTask, id  _Nullable responseObject) {
        
        NSArray<MK_HomeCategoryModel*>* resArr = [NSArray yy_modelArrayWithClass:[MK_HomeCategoryModel class] json:responseObject[@"data"]];
        if (backBlock) {
            backBlock(resArr);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable dataTask, NSError * _Nonnull error) {
        if (failBlock) {
            failBlock(error);
        }
    }];
}

/// 获得首页轮播器的模型数据
-(void)MK_getHomeSlideItemArrWithBackBlock:(void(^)(NSArray<MK_HomeSlideItem*>* res))backBlock andFailBlock:(void(^)(NSError *err))failBlock {
    NSString* url = @"https://capi.douyucdn.cn/api/v1/slide/6";
    [[MK_NetWorking sharedNetWorking]Miku_GET:url parameters:@{@"version":@"2.490"} progress:nil success:^(NSURLSessionDataTask * _Nonnull dataTask, id  _Nullable responseObject) {
        NSArray<MK_HomeSlideItem*>* resArr = [NSArray yy_modelArrayWithClass:[MK_HomeSlideItem class] json:responseObject[@"data"]];
        if (backBlock) {
            backBlock(resArr);
        }
    } failure:^(NSURLSessionDataTask * _Nullable dataTask, NSError * _Nonnull error) {
        if (failBlock) {
            failBlock(error);
        }
    }];
}

/// 得到推荐热门房间信息
-(void)MK_getHotRoomDataWithBackBlock:(void(^)(NSArray<MK_HotRoomModel*>* res))backBlock andFailBlock:(void(^)(NSError *err))failBlock {
    NSString* url = @"https://capi.douyucdn.cn/api/v1/getHotCate";
    [[MK_NetWorking sharedNetWorking]Miku_GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull dataTask, id  _Nullable responseObject) {
        NSArray<MK_HotRoomModel*>* resArr = [NSArray yy_modelArrayWithClass:[MK_HotRoomModel class] json:responseObject[@"data"]];
        if (backBlock) {
            backBlock(resArr);
        }
    } failure:^(NSURLSessionDataTask * _Nullable dataTask, NSError * _Nonnull error) {
        if (failBlock) {
            failBlock(error);
        }
    }];
}

/// 得到其他分类热门房间
-(void)MK_GetCategoryHotDataWithID:(NSString*)ID andBackBlock:(void(^)(NSArray<MK_HotRoomModel*>* res))backBlock andFailBlock:(void(^)(NSError *err))failBlock {
    NSString* url = @"https://capi.douyucdn.cn/api/homeCate/getHotRoom";
    [[MK_NetWorking sharedNetWorking]Miku_GET:url parameters:@{@"identification":ID} progress:nil success:^(NSURLSessionDataTask * _Nonnull dataTask, id  _Nullable responseObject) {
        NSArray<MK_HotRoomModel*>* resArr = [NSArray yy_modelArrayWithClass:[MK_HotRoomModel class] json:responseObject[@"data"]];
        if (backBlock) {
            backBlock(resArr);
        }
    } failure:^(NSURLSessionDataTask * _Nullable dataTask, NSError * _Nonnull error) {
        if (failBlock) {
            failBlock(error);
        }
    }];
}




@end
